package com.colin.aiyi.presenter.Imp_de;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.colin.aiyi.dao.ImpxUtils3_de.IService;
import com.colin.aiyi.dao.ImpxUtils3_de.ImpReferrer;
import com.colin.aiyi.entity.response.BaseResponse;
import com.colin.aiyi.entity.YiMing;
import com.colin.aiyi.ui.Home.chudao.IViewReferrer;
import com.colin.aiyi.presenter.Interface_Derecated.AbsPresenter;

/**
 * Created by hl on 2017/6/6.
 */
@Deprecated
public class ImpPReferrer extends AbsPresenter<YiMing> {
    IService<YiMing> iService=new ImpReferrer();
    IViewReferrer iviewReferrer;

    public ImpPReferrer(IViewReferrer iviewReferrer) {
        this.iviewReferrer = iviewReferrer;
    }

    @Override
    public void onSuccess(Object t) {
        if (t instanceof YiMing)
        {
          //iviewReferrer.bindYiMing2View((YiMing) t);
        }
        if (t instanceof BaseResponse)
        {
            iviewReferrer.refreshStatus((BaseResponse) t);
        }
    }


    /**********
     * 详情
     *
     */

    @Override
    public void getTById(String id) {
        super.getTById(id);
        iService.getTById(this,id);
    }

    /********
     * 修改
     * roleId	是	string	角色ID
     content	是	string	内容
     urls	是	string	多个用字符串拼接
     * @param yiMing
     */
    @Override
    public void updateT(YiMing yiMing) {
       iService.updateT(this,yiMing);
    }

    /******
     * POST
     参数：

     参数名	必选	类型	说明
     roleId	是	string	角色ID
     content	是	string	内容
     urls	是	string	多个用字符串拼接
     * @param yiMing
     */
    @Override
    public void saveT( YiMing yiMing) {
        iService.saveT(this,yiMing);
    }


    @Override
    public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
        super.onItemChildClick(adapter, view, position);
        if (position+1==adapter.getData().size()){
            adapter.getData().add(new YiMing.DataBean.UrlsBean());
            adapter.notifyItemInserted(adapter.getData().size());
            view.getBackground().setLevel(1);
        }else {
            view.getBackground().setLevel(0);
            adapter.getData().remove(position);
            adapter.notifyItemRemoved(position);

        }

    }
}
